//
//  PrimaryClassificationCell.m
//  BaseProject
//
//  Created by 王洋 on 2020/7/20.
//  Copyright © 2020 王洋. All rights reserved.
//

#import "PrimaryClassificationCell.h"

@implementation PrimaryClassificationCell

- (void)awakeFromNib {
    [super awakeFromNib];

}

- (void)fillCellWithModel:(ProClassificationModel *)model {
    
    self.model = model;
    [self.mainImageView sd_setImageWithURL:[NSURL URLWithString:model.icon]  placeholderImage:[UIImage imageNamed:@"placeholder"]];
    self.mainTitleLab.text = [NSString stringWithFormat:@" %@ ",model.parentName];
}


- (void)layoutSubviews {
    [super layoutSubviews];
    
    if (self.model.isSelect) {
        
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            [self.mainImageView pp_clipCorners:UIRectCornerAllCorners radius:self.mainImageView.frame.size.height/2 border:1 color:UIColorHex(0xff4242)];
            
            self.mainTitleLab.textColor = UIColorHex(0xffffff);
            self.mainTitleLab.layer.backgroundColor = UIColorHex(0xFF5252).CGColor;
            self.mainTitleLab.layer.cornerRadius = self.mainTitleLab.frame.size.height/2;
        });
    } else {
        
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            [self.mainImageView pp_clipCorners:UIRectCornerAllCorners radius:self.mainImageView.frame.size.height/2 border:1 color:UIColorHex(0xffffff)];
            
            self.mainTitleLab.textColor = UIColorHex(0x666666);
            self.mainTitleLab.layer.backgroundColor = UIColorHex(0xffffff).CGColor;
            self.mainTitleLab.layer.cornerRadius = self.mainTitleLab.frame.size.height/2;
        });
    }
}

- (ProClassificationModel *)model {
    if (!_model) {
        _model = [[ProClassificationModel alloc] init];
    }
    return _model;
}

@end
